HAL SDIO interrupt handler and callbacks

This section provides information about the HAL SDIO IRQ handler and callback migration.

HAL SDIO interrupt request handler

HAL1

HAL2

void HAL_SDIO_IRQHandler(SDIO_HandleTypeDef *hsdio)
void HAL_SDIO_IRQHandler(hal_sdio_handle_t *hsdio)

HAL SDIO default callbacks

In HAL1, separate TX and RX transfer complete callbacks are provided for handling transmit and receive events individually.

In HAL2, a unified transfer complete callback function is used, with an additional parameter to indicate whether the event is a TX or RX transfer.

HAL1

HAL2

void HAL_SDIO_TxCpltCallback(SDIO_HandleTypeDef *hsdio)
void HAL_SDIO_RxCpltCallback(SDIO_HandleTypeDef *hsdio)

void HAL_SDIO_ErrorCallback(SDIO_HandleTypeDef *hsdio)

void HAL_SDIO_IOFunctionCallback(SDIO_HandleTypeDef *hsdio,
                                 uint32_t func)

void HAL_SDIO_DriveTransceiver_1_8V_Callback(SDIO_HandleTypeDef *hsdio,
                                             FlagStatus status)
void HAL_SDIO_XferCpltCallback(hal_sdio_handle_t *hsdio,
                           hal_sdio_event_cb_t cb_event)

void HAL_SDIO_ErrorCallback(hal_sdio_handle_t *hsdio)

void HAL_SDIO_IOFunctionCallback(hal_sdio_handle_t *hsdio,
                                 uint32_t func)

void HAL_SDIO_DriveTransceiver_1_8V_Callback(hal_sdio_handle_t *hsdio,
                                             hal_sdio_transceiver_state_t state)

HAL SDIO register IO function callback

HAL1

HAL2

HAL_StatusTypeDef HAL_SDIO_RegisterIOFunctionCallback(SDIO_HandleTypeDef *hsdio,
                                  uint32_t IOFunction,
                                  HAL_SDIO_IOFunction_CallbackTypeDef pCallback)
hal_status_t HAL_SDIO_RegisterIOFunctionCallback(hal_sdio_handle_t *hsdio,
                                       hal_sdio_function_t io_function,
                                       hal_sdio_io_function_cb_t callback)

HAL SDIO register identify card callback

HAL1

HAL2

HAL_StatusTypeDef HAL_SDIO_RegisterIdentifyCardCallback(SDIO_HandleTypeDef *hsdio,
                                      pSDIO_IdentifyCardCallbackTypeDef pCallback)

Sequence changed, see below note.

Note

  • In HAL1, the function HAL_SDIO_RegisterIdentifyCardCallback() is used to register a user-defined (custom) callback for identifying the SDIO card.

  • In HAL2, this user’s function is no longer registered as a callback. Instead, the function is passed directly as the third parameter to HAL_SDIO_SetConfig().

  • To use the default implementation, simply pass NULL instead. Refer to HAL SDIO configuration and card identification sequence for a practical use case.


HAL SDIO register transceiver callback

HAL1

HAL2

HAL_StatusTypeDef HAL_SDIO_RegisterTransceiverCallback(SDIO_HandleTypeDef *hsdio,
                                      pSDIO_TransceiverCallbackTypeDef pCallback)
hal_status_t HAL_SDIO_RegisterTransceiverCallback(hal_sdio_handle_t *hsdio,
                                        hal_sdio_transceiver_cb_t callback)

HAL SDIO register callbacks

HAL1

HAL2

In HAL1, the function HAL_SDIO_RegisterCallback is used to register SDIO callbacks using a single function with a specific callback ID.

In HAL2, separate functions are available to register each specific SDIO callback. The MSP init and deinit callbacks are removed; users must handle hardware initialization and deinitialization manually, refer to Initialization and de-initialization sequence for more details.

Examples to migrating the callbacks registration

HAL1

HAL2

HAL_SDIO_RegisterCallback(hsdio,
                          HAL_SDIO_TX_CPLT_CB_ID,
                          USER_SDIO_TxCpltCallback)

HAL_SDIO_RegisterCallback(hsdio,
                          HAL_SDIO_RX_CPLT_CB_ID,
                          USER_SDIO_RxCpltCallback)
HAL_SDIO_RegisterXferCpltCallback(hsdio,
                           USER_SDIO_XferCpltCallback)

Note

One event callback function handles all transfer complete events with an additional parameter to specify the event type.

HAL_SDIO_RegisterCallback(hsdio,
                          HAL_SDIO_ERROR_CB_ID,
                          USER_SDIO_ErrorCallback)
HAL_SDIO_RegisterErrorCallback(hsdio,
                               USER_SDIO_ErrorCallback)
HAL_SDIO_RegisterCallback(hsdio,
                          HAL_SDIO_MSP_DEINIT_CB_ID,
                          USER_SDIO_MspDeInitCallback)

HAL_SDIO_RegisterCallback(hsdio,
                          HAL_SDIO_MSP_INIT_CB_ID,
                          USER_SDIO_MspInitCallback)

The MSP init and deinit callbacks are removed. Users must handle hardware initialization and deinitialization in application code. Refer to Initialization and de-initialization sequence for more details.

Related concepts:


HAL SDIO unregister callbacks

HAL1

HAL2

In HAL1, the function HAL_SDIO_UnRegisterCallback is used to unregister SDIO callbacks using a single function with a specific callback ID.

In HAL2, unregister APIs are removed; users can simply register the default weak callbacks using the HAL SDIO register callback APIs.

Examples to migrating the callbacks registration

HAL1

HAL2

HAL_SDIO_UnRegisterCallback(hsdio,
                          HAL_SDIO_TX_CPLT_CB_ID)

HAL_SDIO_UnRegisterCallback(hsdio,
                          HAL_SDIO_RX_CPLT_CB_ID)
HAL_SDIO_RegisterXferCpltCallback(hsdio,
                           HAL_SDIO_XferCpltCallback)

Note

One event callback function handles all transfer complete events with an additional parameter to specify the event type.

HAL_SDIO_UnRegisterCallback(hsdio,
                          HAL_SDIO_ERROR_CB_ID)
HAL_SDIO_RegisterErrorCallback(hsdio,
                               HAL_SDIO_ErrorCallback)
HAL_SDIO_UnRegisterCallback(hsdio,
                            HAL_SDIO_MSP_DEINIT_CB_ID)

HAL_SDIO_UnRegisterCallback(hsdio,
                            HAL_SDIO_MSP_INIT_CB_ID)

The MSP init and deinit callbacks are removed. Users must handle hardware initialization and deinitialization in application code. Refer to Initialization and de-initialization sequence for more details.

Related concepts: